<?php $user = $user[$id]; ?>
<div class="user-info row no-gutter">
    <figure id="user-photo" class="span2 no-gutter">
        <?php if($user['image']!=''): ?>
            <img src="<?php echo base_url($this->config->item('image_user_path').$user['image']); ?>" title="<?php echo $user['name']; ?>" class="thumbnail span1 no-gutter"/>
        <?php else: ?>
            <img src="<?php echo place_img(108,'','4d99e0','fff','jpg','Profil'); ?>" title="<?php echo $user['name']; ?>" class="thumbnail span1 no-gutter"/>
        <?php endif; ?>
    </figure>
    <section id="user-meta" class="span3">
        <h2><?php echo $user['name']; ?></h2>
        <table>
            <tbody>
                <tr>
                    <th>E-mail:</th>
                    <td><?php echo $user['email']; ?></td>
                </tr>
                <tr>
                    <th>Telefon:</th>
                    <td><?php echo $user['phone']; ?></td>
                </tr>
                <tr>
                    <th>Data urodzenia:</th>
                    <td><?php echo $user['birth']; ?></td>
                </tr>
            </tbody>
        </table>
    </section>
    <section id="team-meta" class="span3">
        <?php foreach($user['teams'] as $ti=>$tv) 
        {
            if($tv['active']==1): ?>
            <figure id="team-photo" class="span1 no-gutter">
                <?php if($tv['logo']!=''): ?>
                    <img src="<?php echo base_url($this->config->item('image_team_path').$tv['logo']); ?>" title="<?php echo $tv['name']; ?>" class="thumbnail span1 no-gutter"/>
                <?php else:?>
                    <img src="<?php echo place_img(108,'','4d99e0','fff','jpg','Logo'); ?>" title="<?php echo $tv['name']; ?>" class="thumbnail span1 no-gutter"/>
                <?php endif; ?>
            </figure>
            <h3 class="span2"><?php echo $tv['name']; ?></h3>
            <table class="span2">
                <tbody>
                    <tr>
                        <th>Liga:</th>
                        <td>
                            <?php
                            $myidx = 1;
                            foreach($tv['comp'] as $ci=>$cv)
                            {
                                if(!empty($cv['code']))
                                    echo '<abbr title"'.$cv['name'].'">'.$cv['code'].'</abbr> - '.$tv['league'][$myidx]['name'].'<br/>';
                                else
                                    echo $cv['name'].'</abbr> - '.$tv['league'][$myidx].'<br/>';
                            }
                            ?>
                        </td>
                    </tr>
                </tbody>
            </table>
            <?php endif;
        }
        ?>
    </section>
</div>
<div id="team-info" class="row">
    <section class="small-league span4">
        <table class="table table-striped table-condensed no-gutter tablesorter span4">
            <thead>
                <tr>
                    <th></th>
                    <th>Nazwa</th>
                    <th>Mecze</th>
                    <th>Punkty</th>
                    <th><abbr title="Bramki zdobyte">+</abbr></th>
                    <th><abbr title="Bramki stracone">-</abbr></th>
                    <th><abbr title="Różnica bramek">+/-</abbr></th>
                </tr>
            </thead>
            <tbody>
            <?php 
            $i=1;
            foreach($teams['comp'] as $c)
            {
                foreach($c['league'] as $liga)
                {
                    echo '<h3>'.$c['code'].' '.$liga['sezon'].' - '.$liga['code'].'</h3>'; 
                    foreach($liga['teams'] as $tk=>$tv)
                    {
                        $sort_points[]  = $tv['points'];
                        $sort_goaldiff[]= $tv['goal_for']-$tv['goal_against'];
                    }
                    array_multisort($sort_points,SORT_DESC,$sort_goaldiff,SORT_DESC,$liga['teams']);
                    foreach($liga['teams'] as $t)
                    {
                        echo '<tr>'
                                .'<td>'.$i.'</td>'
                                .'<td>'.($t['id']==$this->config->item('ut_team') ? '<strong>'.$t['name'].'</strong>' : $t['name']).'</td>'
                                .'<td>'.$t['played'].'</td>'
                                .'<td>'.$t['points'].'</td>'
                                .'<td>'.$t['goalfor'].'</td>'
                                .'<td>'.$t['goalaga'].'</td>'
                                .'<td>'.($t['goalfor']-$t['goalaga']).'</td>'
                            .'</tr>';
                        $i++;
                    }
                }   
                $i++;
            } ?>
            </tbody>
        </table>
    </section>
    <section class="small-stats span2">
        <h3>Statystyki</h3>
        <table class="table table-striped table-condensed no-gutter">
            <thead>
                <tr>
                    <td></td>
                    <th><abbr title="Mecze rozegrane">M</abbr></th>
                    <th><abbr title="Gole strzelone"><span class="goal">G</span></abbr></th>
                    <th><abbr title="Żółte kartki"><span class="yellow-card">Ż</span></abbr></th>
                    <th><abbr title="Czerwone kartki"><span class="red-card">CZ</span></abbr></th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <th>Sezon 2011/2012:</th>
                    <td>26</td>
                    <td>1</td>
                    <td>0</td>
                    <td>0</td>
                </tr>
            </tbody>
        </table>
    </section>
    <section id="positions" class="span2">
        <h3>Pozycje</h3>
        <div id="pitch">
            <?php foreach($user['pozycje'] as $pi=>$pv)
            {
                if($pv['active'])
                {
                    $pos = '<div class="player-position';
                    switch($pv['id'])
                    {
                        case 1:
                            $pos .= ' play-gk';
                            break;
                        case 2:
                            $pos .= ' play-op';
                            break;
                        case 3:
                            $pos .= ' play-os';
                            break;
                        case 4:
                            $pos .= ' play-ol';
                            break;
                        case 5:
                            $pos .= ' play-pp';
                            break;
                        case 6:
                            $pos .= ' play-ps';
                            break;
                        case 7:
                            $pos .= ' play-pl';
                            break;
                        case 8:
                            $pos .= ' play-n';
                            break;
                        default:
                            $pos .= '';
                            break;                        
                    }
                    $pos.= '">'.$pi;
                    $pos.='</div>';
                    echo $pos;
                }
                    
            }    
            ?>
        </div>
    </section>
</div>